select mere.id as id_mere,brand,products_lang.name as product_name,min(products.price) as minprice,min(products.price_csv) as minprice_csv,max(discount) as offer,max(products.id) as id_product,max(benefici) as cash,sum(stock) as tstock,sum(products.units_sold) as unitssold from products,mere,products_lang where num_images>0 and mere.id=products.id_mere and mere.id=products_lang.id_mere and products_lang.lang='es' and stock>0 and id_category='16' and brand in ('aran jewels') and gender in ('male') group by mere.id ,brand,products_lang.name order by cash desc, tstock desc, num_images desc limit 0,30